feat: implement lazy loading for CLI groups#8472
Merged
Merged
Conversation
bchampp
marked this pull request as ready for review
December 1, 2025 19:12
reedham-aws
previously approved these changes
Dec 1, 2025
reedham-aws
left a comment
Contributor
There was a problem hiding this comment.
Approving because I think it's good as is, just had one small suggestion
Vandita2020
reviewed
Dec 1, 2025
Vandita2020
previously approved these changes
Dec 1, 2025
reedham-aws
approved these changes
Dec 1, 2025
Vandita2020
approved these changes
Dec 1, 2025
Member
|
Do we have some before/after data comparison? |
Member
Author
Yeah - I was able to see about a ~300ms difference calling the |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) does this change fix?
Why is this change necessary?
The SAM CLI has many CLI groups now, and we see overhead while running a given command due to SAM needing to import all CLI sub-commands (and the modules they need).
How does it address the issue?
Implementing a lazy CLI group base class based on https://click.palletsprojects.com/en/stable/complex/#lazily-loading-subcommands. This defers imports so we only import the given CLI group when it's the command being run.
What side effects does this change have?
None - defer imports to be lazy loaded. I've added unit tests to validate the
--helpcommands for these CLI groups, but if a requested CLI group doesn't exist (e.g. we're pointing to a non-existing group), the schema generation will fail.Mandatory Checklist
PRs will only be reviewed after checklist is complete
make prpassesmake update-reproducible-reqsif dependencies were changedBy submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.